13. Demo: Building a Strategy
Cd13639 C1 L1 DEMO 6 V1
Understanding the Confusion Matrix and Strategy Enhancement
The sixth demo focuses on leveraging the confusion matrix to refine trading strategy performance, connecting it to several critical metrics:
Metrics Introduced:
- Accuracy: Measures correct predictions.
- Precision: Evaluates prediction accuracy when predicting a positive return.
- Recall: Assesses the ability to detect all positive predictions.
Data Preparation:
- Reload existing data, including historical prices and RSI indicators.
- Establish benchmarks like S&P 500 with metrics like CAGR and Sharpe Ratio.
Confusion Matrix Integration:
- Define binary variables (y_test and y_pred) to calculate confusion matrix components.
- Introduce SK learn library tools to compute accuracy, precision, and recall.
Performance Assessment:
- Initial accuracy at 48%, precision at 53%, with low recall.
Strategy Tweaking:
- Lower the investment threshold to increase trade frequency.
- New strategy shows improved CAGR of 15% and Sharpe Ratio of 0.85.
- Achieves higher recall with lower precision.
Conclusion:
- Adjustments between precision and recall can boost strategy performance, emphasizing the relation between frequent trading and profitability.